/**
 * 利用错误栈堆，取出其中错误提示
 */

function errorFn() {
  const obj = {}

  Error.captureStackTrace(obj)
  const callSite = obj.stack.split('\n')[1]
  const fileName = callSite.match(/\s\((.*):\d+:\d+\)$/)[1]

  console.dir(callSite, { depth: null })
  // '    at Module._compile (internal/modules/cjs/loader.js:701:30)'
  console.log(obj.stack)
  console.log(fileName)
  // internal/modules/cjs/loader.js
}

errorFn()

module.exports = errorFn
